<script setup lang="ts">
import { ref, watchEffect } from "vue";

const msg = ref("飞机");
const msg2 = ref("飞机杯子");

const stop = watchEffect(
  (oninvalidate) => {
    console.log("msg:", msg.value);
    console.log("msg2:", msg2.value);
    oninvalidate(() => {
      console.log("before");
    });
  },
  {
    flush: "pre",
  }
);
</script>

<template>
  <div><input type="text" v-model="msg" /></div>
  <div><input type="text" v-model="msg2" /></div>
  <div><button @click="stop">停止侦听</button></div>
</template>

<style scoped></style>
